<template>
    <div class="heart">
      <el-breadcrumb separator="">
        <el-breadcrumb-item :to="{ path: '/dataReport' }">数据报表</el-breadcrumb-item>
        <el-breadcrumb-item
        ><a></a></el-breadcrumb-item
      >
      </el-breadcrumb>
      <div class="search">
          <el-select
            v-model="area"
            placeholder="行政区域"
            size="large"
            clearable
            style="width: 240px"
            :popper-append-to-body="false"
          >
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
          <el-select
            v-model="instury"
            placeholder="响应等级"
            size="large"
            clearable
            style="width: 240px"
            :popper-append-to-body="false"
          >
            <el-option
              v-for="item in options1"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            />
          </el-select>
        <el-button type="primary" style="width: 80px;">查询</el-button>
      </div>
      <el-card style="height: 70px; margin-top: 20px; position:relative;" shadow="hover">
        <el-button type="primary" style="width: 100px;">添加响应等级</el-button>
      </el-card>
      <el-table
      ref="multipleTableRef"
      :data="tableData"
      style="width: 100%; margin-top: 20px"
      @sort-change="handleSort"
    >
        <el-table-column prop="createTime" label="日期" sortable />
        <el-table-column prop="phAverage" label="行政区域" />
        <el-table-column label="应急响应等级">
          <template #default="scope">
            <span v-if="scope.row.chemistryAverage==1" class="tags" style="color: rgb(255,215,0)">黄色预警</span>
            <span v-if="scope.row.chemistryAverage==2" class="tags" style="color: rgb(255,140,0)">橙色预警</span>
            <span v-if="scope.row.chemistryAverage==3" class="tags" style="color: rgb(255,69,0)">红色预警</span>
          </template>
        </el-table-column>
        <el-table-column prop="chemistryOutput" label="应急响应编号" />
        <el-table-column label="操作" >
            <template #default="scope">
                <el-button>查看状态详情</el-button>
              </template>
        </el-table-column>
    </el-table>
    <div class="pagination">
      <Pagination v-model:page="page"  :total="total" @pagination="getData" />
    </div>
    </div>
      
  </template>
  <script lang="ts" setup>
  import { ref, watch, onMounted, reactive,  } from 'vue'
  import Pagination from '../../components/Pagination.vue'
    let timeRange =  ref('')
    let area = ref()
    let instury = ref()
    const options = [
  {
    value: 1,
    label: '武昌区',
  },
  {
    value: 2,
    label: '汉口区',
  },
  {
    value: 3,
    label: '汉阳区',
  },
]
const options1 = [
  {
    value: 1,
    label: '黄色预警',
  },
  {
    value: 2,
    label: '橙色预警',
  },
  {
    value: 3,
    label: '红色预警',
  },
]
    onMounted(()=>{
      console.log(tableData.value)
    })
    const tableData = ref([
      {
          "id":1,
          "phAverage": "武昌区",
          "chemistryAverage": "1",
          "chemistryOutput": "5551",
          "instantAverage": "1661",
          "instantOutput": "7771",
          "createTime": "2024-05-08",
        },
        {
          "id":2,
          "phAverage": "洪山区",
          "chemistryAverage": "2",
          "chemistryOutput": "5451",
          "instantAverage": "1661",
          "instantOutput": "7771",
          "createTime": "2024-05-07",
        },
        {
          "id":3,
          "phAverage": "洪山区",
          "chemistryAverage": "3",
          "chemistryOutput": "5451",
          "instantAverage": "1661",
          "instantOutput": "7771",
          "createTime": "2024-05-06",
        },
        {
          "id":4,
          "phAverage": "武昌区",
          "chemistryAverage": "2",
          "chemistryOutput": "5545",
          "instantAverage": "1661",
          "instantOutput": "7771",
          "createTime": "2024-05-05",
        },
        {
          "id":5,
          "phAverage": "武昌区",
          "chemistryAverage": "1",
          "chemistryOutput": "2551",
          "instantAverage": "1661",
          "instantOutput": "7771",
          "createTime": "2024-05-04",
        },
        {
          "id":6,
          "phAverage": "洪山区",
          "chemistryAverage": "3",
          "chemistryOutput": "5341",
          "instantAverage": "1661",
          "instantOutput": "7771",
          "createTime": "1981-07-06",
        },
        {
          "id":7,
          "phAverage": "汉口区",
          "chemistryAverage": "1",
          "chemistryOutput": "5346",
          "instantAverage": "1661",
          "instantOutput": "7771",
          "createTime": "2024-05-03",
        },
        {
          "id":8,
          "phAverage": "武昌区",
          "chemistryAverage": "3",
          "chemistryOutput": "1111",
          "instantAverage": "1661",
          "instantOutput": "7771",
          "createTime": "2024-05-02",
        },
        {
          "id":9,
          "phAverage": "汉口区",
          "chemistryAverage": "2",
          "chemistryOutput": "2222",
          "instantAverage": "1661",
          "instantOutput": "7771",
          "createTime": "2024-05-01",
        },
        {
          "id":10,
          "phAverage": "汉口区",
          "chemistryAverage": "2",
          "chemistryOutput": "3333",
          "instantAverage": "1661",
          "instantOutput": "7771",
          "createTime": "2024-04-30",
        },
    ])
    interface Instrument {
      id: number,
      companyName: string,
      outputName: string,
      instrumentName: string,
      instrumentMIN: string,
      password: string,
      isUsing: boolean
    }
    let selected = ref<number[]>([])
    const handleSelectionChange = (a:Instrument[])=>{
      selected.value = [];
      a.forEach((row:Instrument)=>{
        selected.value.push(row.id)
      })
      console.log(selected.value)
    }
  
    let handleSort = (data: {column: any, prop: string, order: any })=>{
      console.log(data)
    }
    let currentPage = ref(1)
    let pageSize = ref(10)
    let total = ref(100)
    let page = ref(1)

  </script>
  <style>
    .heart{
      width: 95%;
      margin: 20px auto;
    }
    .search{
      margin-top: 50px;
      display: flex;
      justify-content: space-around;
    }
    .pagination{
      margin-top: 40px;
      display: flex;
      justify-content: center;
    }
    .tags{
        display: inline-block;
        width: 80px;
        text-align: center;
    }
  </style>